home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group98a.txt
/
000052_icon-group-sender _Tue Feb 24 13:03:15 1998.msg
< prev
next >
Wrap
Internet Message Format
|
2000-09-20
|
3KB
Return-Path: <icon-group-sender>
Received: from kingfisher.CS.Arizona.EDU (kingfisher.CS.Arizona.EDU [192.12.69.239])
by baskerville.CS.Arizona.EDU (8.8.7/8.8.7) with SMTP id NAA05023
for <icon-group-addresses@baskerville.CS.Arizona.EDU>; Tue, 24 Feb 1998 13:03:11 -0700 (MST)
Received: by kingfisher.CS.Arizona.EDU (5.65v4.0/1.1.8.2/08Nov94-0446PM)
id AA29989; Tue, 24 Feb 1998 13:03:11 -0700
Date: Tue, 24 Feb 1998 08:03:36 -0800
From: kwalker@sfo.harbinger.com (Ken Walker)
Message-Id: <199802241603.IAA12817@varda.premenos.com>
To: icon-group@optima.CS.Arizona.EDU, sunyd21@aol.com, mr2r@erols.com
Subject: Re: help with icon programing
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Md5: F7DEN7W/z/Z0i2i1ArEtDw==
Errors-To: icon-group-errors@optima.CS.Arizona.EDU
Status: RO
Content-Length: 1833
> Date: Tue, 24 Feb 1998 01:56:29 -0500
> From: Adnan Khan <mr2r@erols.com>
>
> I am new with this language and I have two questions. I am trying
> to intialize a character in icon language and i don't know how to do
> it. Could you please tell me how to intilize something as a character.
> Second, I am checking if two things or same or not by using an 'if'
> statement. and... my project reads one character and checks if it is '0'
> (zero) or not. As long as the character which is read in from the file
> is an integer the program runs fine, but when it reads a non-integer
> charcter from the file it gives me an error msg. of something like type
> mismatch or something. My first question relates to the same thing. I
> want to declare that the thing read from the file is a character and not
> an integer and then I want to compare them.
Icon has no character data type; it has only character sets and character
strings. The function call, reads(file, 1), returns a character string
of length one. Icon automatically converts been integers and character
strings when it can. It sounds like you are using the integer comparison
operator. This works okay when you read a digit because the digit
is converted to an integer before the comparison, but for a non-digit
character which cannot be converted, it produces an error. You need to
use the string comparison operator:
if chr == "0" then ...
Note that Icon variable declarations contain no type information. In Icon,
it is values not variables that have type. Any variable can have a value
of any type. If you want to determine if a string can be converted to an
integer, you can try an explicit conversion and see if it succeeds or
fails:
if integer(str) then ...
Ken Walker, kwalker@sfo.harbinger.com
Harbinger Coporation, Concord, Ca. 94520